<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace merchant\controllers;

use yii\web\Response;

/**
 * Description of FileController
 *
 * @author Sylar
 */
class FilesController extends \merchant\components\Controller {

    public function actions() {
        return [
            'upload' => [
                'class'                  => 'trntv\filekit\actions\UploadAction',
                'multiple'               => true,
                'disableCsrf'            => true,
                'responseFormat'         => Response::FORMAT_JSON,
                'responsePathParam'      => 'path',
                'responseBaseUrlParam'   => 'base_url',
                'responseUrlParam'       => 'url',
                'responseDeleteUrlParam' => 'delete_url',
                'responseMimeTypeParam'  => 'type',
                'responseNameParam'      => 'name',
                'responseSizeParam'      => 'size',
                'deleteRoute'            => 'delete',
                'fileStorage'            => 'fileStorage', // Yii::$app->get('fileStorage')
                'fileStorageParam'       => 'fileStorage', // ?fileStorage=someStorageComponent
                'sessionKey'             => '_uploadedFiles',
                'allowChangeFilestorage' => false,
                'validationRules'        => [],
                'on afterSave'           => function($event) {
                    /* @var $file \League\Flysystem\File */
                    $file = $event->file;
                    // do something (resize, add watermark etc)
                }
            ],
            'delete' => [
                'class' => 'trntv\filekit\actions\DeleteAction',
            ],
            'view'   => [
                'class' => 'trntv\filekit\actions\ViewAction',
            ],  
            'upload-delete' => [
                'class' => 'trntv\filekit\actions\DeleteAction'
            ],
            'upload-imperavi' => [
                'class' => 'trntv\filekit\actions\UploadAction',
                'fileparam' => 'file',
                'responseUrlParam'=> 'filelink',
                'multiple' => false,
                'disableCsrf' => true
            ]
        ];
    }

}
